home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / tcsel003.zip / ASC2STR.PAS < prev    next >
Pascal/Delphi Source File  |  1992-10-19  |  626b  |  13 lines

  1.  function Asc2Str(var s; max: byte): string;
  2.    { Converts an ASCIIZ string to a Turbo Pascal string }
  3.    { with a maximum length of max.                      }
  4.    var starray  : array[1..255] of char absolute s;
  5.        len      : integer;
  6.    begin
  7.      len        := pos(#0,starray)-1;                       { Get the length }
  8.      if (len > max) or (len < 0) then               { length exceeds maximum }
  9.        len      := max;                                  { so set to maximum }
  10.      Asc2Str    := starray;
  11.      Asc2Str[0] := chr(len);                                    { Set length }
  12.    end;  { Asc2Str }
  13.